import create from "zustand";

// const useCounter = create(()=>{
//   return {
//     count:100
//   }
// })
// 等价于
interface CountType {
  count: number;
  increment: () => void;
  decrement: () => void;
}
export const useCounter = create<CountType>((set) => ({
  count: 100,
  increment() {
    // return set({ count: 6666 }); //将数字改为固定值
    return set((state) => ({ count: state.count + 1 })); //将数字基于原来的值+1
  },
  decrement() {
    return set((state) => ({ count: state.count - 1 })); //将数字基于原来的值+1
  },
}));
